package com.tskj.leonsu.service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.tskj.leonsu.dao.SystemDAO;
import com.tskj.leonsu.websocket.EasyStarSocketUtility;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.IOException;

@Service
public class SystemService {

    @Autowired
    private EasyStarSocketUtility easyStarSocketUtility;

    @Autowired
    private SystemDAO systemDAO;

    public void sendMessageToAll(JSONObject msg) {
        easyStarSocketUtility.sendToAll(msg);
    }

    public JSONArray getModuleList() {
        return systemDAO.getModuleList();
    }

    public void sendMessage(String userToken, JSONObject data) {
        try {
            easyStarSocketUtility.sendMessage(userToken, data);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
